<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="com.situ.student.entity.Student"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<!-- 直接放直接取 c:set -->
	<c:set var="gender" value="男"></c:set> 
	${gender}<hr/>
	
	
	<!-- if条件判断 -->
	<c:set var="age" value="20"></c:set>
	<c:set var="gender" value="女"></c:set>
	<c:if test="${age == 20 }">
		20了
	</c:if>
	
	<!-- 相当于if-else，以上边挨着的取判断值-->
	<c:if test="${gender == '男' }">
		男
	</c:if>
	<c:if test="${gender == '女' }">
		女
	</c:if>
	<hr/>
	
	
	<!-- for-each,没有数据只能写入 -->
	<%
		List<Student> list = new ArrayList<Student>();
		Student student1 = new Student("张三", 34, "男");
		Student student2 = new Student("李四", 34, "男");
		list.add(student1);
		list.add(student2);
		application.setAttribute("list", list);
	%>
	
	<!-- list集合，studnet每次循环生成的变量 -->
	<c:forEach items="${list}" var="student"> 
		${student.name}--${student.age}--${student.gender}
	</c:forEach>
	<br/>
	<hr/>
	
	
	
	<!-- 多条件判断  if-else -->
	<c:set var="score" value="90"></c:set>
	<c:choose>
		<c:when test="${score<=100 && score>=90}">
			优秀
		</c:when>
		<c:when test="${score<100 && score>=90}">
			良好
		</c:when>
		<c:otherwise>
			不及格
		</c:otherwise>
	</c:choose>
	<hr/>

	<!-- for循环 -->
	<c:forEach begin="1" end="5" var="i">
		${i}
	</c:forEach>
	<hr/>
	<!-- 遍历map<string string> -->
	<%
		Map<String,String> map = new HashMap<String,String>();
		map.put("cn", "中国");
		map.put("us", "美国");
		request.setAttribute("map", map);
	%>
	<c:forEach items="${map}" var="entry">
		${entry.key}---${entry.value}
	</c:forEach>
	<hr/>
	
	<!-- 遍历map<string student> -->
	<%
		Student stu1 = new Student("李四",23,"男");
		Student stu2 = new Student("王五",33,"男");
		Map<String,Student> map2 = new HashMap<String, Student>();
		map2.put("stu1", stu1);
		map2.put("stu2", stu2);
		request.setAttribute("map2", map2);
	%>
	
	<c:forEach items="${map2}" var="entry">
		 ${entry.key}---${entry.value}<br/>
		 ${entry.key}---${entry.value.name}<br/>
	</c:forEach>
	
--------------------------------------------------------------------------------<br/>	
<!-- ------------------------------------------------------------------------ -->	
	<!-- 单条件判断if -->
	<c:set var="age" value="23"></c:set>
	${age}<br/>
	<c:if test="${age>20}">
		青年
	</c:if>
	<c:if test="${age<20}">
		少年
	</c:if>
	<hr/>
	
	<!-- 多条件判断if-else -->
	<c:set var="score" value="88"></c:set>
	${score}
	<c:choose>
		<c:when test="${score<=100 && score>=90}">
			优秀
		</c:when>
		<c:when test="${score<90 && score>=80}">
			良好
		</c:when>
		<c:otherwise>
			不及格
		</c:otherwise>
	</c:choose>
	<hr/>
	
	<!-- List<student>遍历 -->
	<%
		List<Student> lists = new ArrayList<Student>();
		Student stud1  = new Student("张三",112,"男");
		Student stud2  = new Student("李四",112,"男");
		lists.add(stud1);
		lists.add(stud2);
		application.setAttribute("lists", lists);
	%>
	<c:forEach items="${lists}" var="student">
		${student.name}--${student.age}--${student.gender}
	</c:forEach>
	<hr/>
	
	<!-- 遍历Map<String,String> -->
	<%
		Map<String,String> map3 = new HashMap<String,String>();
		map.put("cn", "中国");
		map.put("us", "美国");
		request.setAttribute("map", map);
	%>
	<c:forEach items="${map}" var="entry" >
		${entry.key}---${entry.value}<br/>
	</c:forEach>
	<hr/>
	
	<!-- 遍历Map<String,Student> -->
	<%
	Student s1  = new Student("张三",112,"男");
	Student s2  = new Student("李四",113,"男");
	Map<String,Student> map1 = new HashMap<String,Student>();
	map1.put("s1", s1);
	map1.put("s2", s2);
	pageContext.setAttribute("map1", map1);
	%>
	<c:forEach items="${map1}" var="entry">
		${entry.key}---${entry.value}<br/>
		${entry.key}---${entry.value.age}<br/>
	</c:forEach>
	<hr/>
	
	<%
	Map<String,String> map4 = new HashMap<String,String>();
	map.put("cn", "中国");
	map.put("jp", "日本");
	request.setAttribute("map", map);
	%>
	<c:forEach items="${map}" var="entry">
		${entry.key}--${entry.value}<br/>
	</c:forEach>
</body>
</html>